<template>
	<view :class="isShowEmptyData ? 'content-empty' : 'content-empty'">
		<view class="empty_data" v-if="isShowEmptyData">
			<view class="empty_data_content">
				<image class="empty_data_image" src="../../../../../static/empty_data.png" mode="widthFix"></image>
				<view class="empty_data_title">暂无数据</view>
			</view>
		</view>
		<view v-else style="height: 100%;width: 100%;">
			<map style="height: 100%;width: 100%;" :latitude="buildInfo.latitude" :longitude="buildInfo.longitude" :markers="covers"></map></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			buildInfo: {},
			covers: [
				{
					latitude: 0,
					longitude: 0,
					iconPath: '../../../../../static/location.png'
				}
			],
			isShowEmptyData: true
		};
	},
	onLoad(e) {
		uni.request({
			url: 'https://baiyi.kent.work/api/v1/system/getBuildDetail',
			method: 'POST',
			data: {
				id: e.id
			},
			success: res => {
				console.log(res);
				if (res.data.code == 200) {
					this.isShowEmptyData = false;
					this.buildInfo = res.data.data.buildInfo;
					this.covers[0].latitude = parseFloat(this.buildInfo.latitude);
					this.covers[0].longitude = parseFloat(this.buildInfo.longitude);
					uni.setNavigationBarTitle({
						title:this.buildInfo.name
					})
				} else {
					uni.setNavigationBarTitle({
						title:"暂无数据"
					})
					this.isShowEmptyData = true;
				}
			},
			fail: e => {
				uni.setNavigationBarTitle({
					title:"暂无数据"
				})
				this.isShowEmptyData = true;
			}
		});
	},
	methods: {}
};
</script>

<style></style>
